package mapper.account;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import pojo.account.Reader;

import java.util.List;

public interface ReaderMapper {
    @Insert("INSERT INTO reader(id,password,name,phone,address) VALUES (#{id},#{password},#{name},#{phone},#{address})")
    boolean insert(Reader reader) throws Exception;

    @Select("SELECT * FROM reader WHERE id=#{id}")
    Reader query(@Param("id") String id);

    @Select("SELECT * FROM reader")
    List<Reader> queryAll();

    @Select("SELECT * FROM reader WHERE id like '%${id}%'")
    List<Reader> queryAllById(@Param("id") String id);
    @Select("SELECT * FROM reader WHERE name like '%${name}%'")
    List<Reader> queryAllByName(@Param("name") String name);

    @Update("UPDATE reader SET id=#{id},password=#{password},name=#{name},phone=#{phone},address=#{address} WHERE id=#{id}")
    boolean update(Reader reader);
}
